//
//  NSDate+Additions.m
//  HSCategoryKit
//
//  Created by huang on 2018/8/1.
//

#import "NSDate+Additions.h"

@implementation NSDate (Additions)

#pragma mark 将0时区的时间戳转成0时区的时间
+ (NSDate *)transformToDateWithTimestamp:(NSString *)timestamp
{
    NSTimeInterval inter = [timestamp doubleValue];
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:inter];
    return date;
}

#pragma mark 将8时区的时间文本格式（“2015-12-13 13：34：45”）转成 0时区的NSDate
+ (NSDate *)transformToDateWithString:(NSString *)string
{
    NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setLocale:[NSLocale currentLocale]];
    [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *date = [df dateFromString:string];
    return date;
}

@end
